package com.ruoyi.center.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.center.domain.CenterBasic;
import com.ruoyi.center.service.ICenterBasicService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 中心基本信息Controller
 * 
 * @author ruoyi
 * @date 2025-11-08
 */
@RestController
@RequestMapping("/center/basic")
public class CenterBasicController extends BaseController
{
    @Autowired
    private ICenterBasicService centerBasicService;

    /**
     * 查询中心基本信息列表
     */
    @PreAuthorize("@ss.hasPermi('center:basic:list')")
    @GetMapping("/list")
    public TableDataInfo list(CenterBasic centerBasic)
    {
        startPage();
        List<CenterBasic> list = centerBasicService.selectCenterBasicList(centerBasic);
        return getDataTable(list);
    }

    /**
     * 导出中心基本信息列表
     */
    @PreAuthorize("@ss.hasPermi('center:basic:export')")
    @Log(title = "中心基本信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CenterBasic centerBasic)
    {
        List<CenterBasic> list = centerBasicService.selectCenterBasicList(centerBasic);
        ExcelUtil<CenterBasic> util = new ExcelUtil<CenterBasic>(CenterBasic.class);
        util.exportExcel(response, list, "中心基本信息数据");
    }

    /**
     * 获取中心基本信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('center:basic:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(centerBasicService.selectCenterBasicById(id));
    }

    /**
     * 新增中心基本信息
     */
    @PreAuthorize("@ss.hasPermi('center:basic:add')")
    @Log(title = "中心基本信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CenterBasic centerBasic)
    {
        return toAjax(centerBasicService.insertCenterBasic(centerBasic));
    }

    /**
     * 修改中心基本信息
     */
    @PreAuthorize("@ss.hasPermi('center:basic:edit')")
    @Log(title = "中心基本信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CenterBasic centerBasic)
    {
        return toAjax(centerBasicService.updateCenterBasic(centerBasic));
    }

    /**
     * 删除中心基本信息
     */
    @PreAuthorize("@ss.hasPermi('center:basic:remove')")
    @Log(title = "中心基本信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(centerBasicService.deleteCenterBasicByIds(ids));
    }
}
